#ifndef SWAMRSOCKETSERVER_H
#define SWAMRSOCKETSERVER_H
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
//#include <sys/time.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include <arpa/inet.h>
#include <fcntl.h>
#include <string>
#include <queue>
#include <vector>
#include <ctime>
#include <iostream>
//#include "socketTest.h"
#define PORT    5555
#define MAXMSG  26197
using namespace std;
using namespace std;
//! an exception to throw if something wrong happens
class swarmNetworkException : public exception
{
	private:
		string message;
	public:
		swarmNetworkException(string s = "");
		string getMessage() const;
		virtual const char* what() const throw();
		virtual ~swarmNetworkException() throw();	

};
//! a server to listen for incoming messages from a client
class swarmSocketServer {
	private:
	//! the port number and the socket
	int pt, sock;
	//! depreciated a boolean for whether the server holds on read 
	bool sync;
	//! sets of socket fields
	fd_set active_fd_set, read_fd_set;
	//! struct to hold client name
	struct sockaddr_in clientname;
	//! struct to hold timeout value
	struct timeval tv;
	//! a variable for holding the size of clients
       	size_t size;
	public:
	//! \param pt sets port 
	swarmSocketServer(int pt);
	//! not implemented 
	bool check();
	/*! reads messages from a client
	 * \param sec is the number of seconds before timeout, holds if negative
	 * \param mess is the number of microsecond before timeout
	 * \return the messages in the receiving buffer
	 */
	vector<vector<string> > read(int sec = 0, int usec = 0);
	//! destructor closes socket 
	~swarmSocketServer();
	//! not implemented
	string getIPv4();

};
#endif
